<template>
	<view>
		<h4>1. 按指引填企业信息，直至出现数据采集中</h4>
		<h4>2. 等待下方出现<span style="color: #007aff;">采集成功 获取结果</span>后，支付即可获取</h4>
		<web-view  :fullscreen="false" :webview-styles="webviewStyles" :src="authUrl"
			style="width: 100%;height: 1200rpx;margin-top: 3px;"></web-view>
		<h4 v-show="result" type="primary" id="dbjz" @click="ljhq">采集成功 获取结果</h4>
	</view>
</template>

<script>
	import {
		taxesStatus
	} from '@/api/jinjian.js'

	export default {
		data() {
			return {
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				},
				id: null,
				authUrl: null,
				result: false
			}
		},
		onLoad(event) {
			console.log('---event---', event)
			if (event.id) {
				this.id = event.id
			}
			if (event.url) {
				this.authUrl = decodeURIComponent(event.url)
			}
		},
		mounted() {
			if (!this.id) {
				return
			}
			// 开始轮询结果
			var lxGather = window.setInterval(() => {
				taxesStatus(this.id).then(res => {
					if (res.code == 202) {
						console.warn('---轮询结果---', res)
					} else {
						clearInterval(lxGather)
						if (res.code == 501) {
							// this.$modal.msg(res.msg)
						} else if (res.code == 204) {
							// 未支付
							this.$tab.navigateTo('/pages/loading?id=' + this.id)
						} else if (res.code == 200) {
							this.$tab.navigateTo('/pages/com?orderNo=' + res.data)
						}
					}
				})
			}, 10000)
		}
	}
</script>

<style lang="scss">
	h4 {
		margin-top: 5px;
		text-align: center;
	}

	#dbjz {
		position: absolute;
		bottom: 0;
		width: 100%;
		padding: 8px;
		background: #007aff;
		color: #fff;
	}
</style>